//
//  YUNTabBar.m
//  BaiSi
//
//  Created by warm on 17/8/12.
//  Copyright © 2017年 hp. All rights reserved.
//

#import "YUNTabBar.h"

@interface YUNTabBar()


@property(nonatomic,weak)UIButton *plusButton;

@end

@implementation YUNTabBar



-(UIButton *)plusButton
{


if(_plusButton==nil)

{

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn setImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal];
    
    [btn setImage:[UIImage imageNamed:@"tabBar_publish_click_icon"] forState:UIControlStateHighlighted];

    [btn sizeToFit];
    [self addSubview:btn];
    
    _plusButton=btn;

}return _plusButton;

}



-(void)layoutSubviews
{
    [super layoutSubviews];
    
    NSInteger count=self.items.count;
    CGFloat btnW=self.bounds.size.width/(count+1);
    CGFloat btnH=self.bounds.size.height;
    CGFloat x=0;
    int i=0;
    
    for (UIView *tabBarButton in self.subviews) {
        
        
        if([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")])
        {
        
        
        if(i==2)
        {
        
            i+=1;
            
        
        }
            x=i*btnW;
            tabBarButton.frame=CGRectMake(x, 0, btnW, btnH);
            i++;
        
        }
        
        
        
    }



    // 调整发布按钮位置
    self.plusButton.center = CGPointMake(self.bounds.size.width * 0.5, self.bounds.size.height * 0.5);


}














@end
